package cn.edu.neusoft.yuejian_02.fragment;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

import cn.edu.neusoft.yuejian_02.R;
import cn.edu.neusoft.yuejian_02.adapter.MatchAdapter;
import cn.edu.neusoft.yuejian_02.listener.RetrofitListener;
import cn.edu.neusoft.yuejian_02.model.MatchModel;

/**
 * A simple {@link Fragment} subclass.
 */
public class MatchListFragment extends Fragment implements View.OnClickListener,RetrofitListener {
    private RecyclerView matchlist;
    private View view=null;

    public MatchListFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        view = inflater.inflate(R.layout.fragment_match_list, container, false);

        initView();
        initData();

        return view;
    }

    private void initData() {
        MatchModel matchModel = new MatchModel();
        matchModel.MatchList(this);
      /*  call.enqueue(new Callback<List<MatchBean>>() {
            @Override
            public void onResponse(Call<List<MatchBean>> call, Response<List<MatchBean>> response) {
                List Match = response.body();

                matchlist.setAdapter(new MatchAdapter(getActivity(),Match));

            }

            @Override
            public void onFailure(Call<List<MatchBean>> call, Throwable t) {

            }
        });*/
    }

    private void initView() {
        matchlist = (RecyclerView) view.findViewById(R.id.matchlist);
        matchlist.setLayoutManager(new LinearLayoutManager(this.getActivity()));
    }


    @Override
    public void onClick(View view) {

    }

    @Override
    public void onSuccess(Object o) {
        List Match = (List) o;

        matchlist.setAdapter(new MatchAdapter(getActivity(),Match));
    }

    @Override
    public void onFail() {

    }
}
